window.onload = function () {
    let username;
    let password;
    /*axios.post("http://localhost:8080/Barbr/?action=logIn").then(res => {
        if(res.data.state){
            username = document.getElementById("username");
            password = document.getElementById("password");
            username.value = res.data.username;
            password.value = res.data.password;
        }else{
            username.value = null;
            password.value = null;
        }
    })*/
}

var remember = true;
function setRememberMe(){
    remember = !remember;
    console.log(remember);
}
function toLogin(){
    var username = document.getElementById("username");
    var password = document.getElementById("password");
    let params = new URLSearchParams();
    params.append("username",username.value);
    params.append("password",password.value);
    params.append("rememberMe",remember);

    if(username.value === ""){
        alert("请输入用户名！");
    }else if(password.value === ""){
        alert("请输入密码！");
    }else{
//{"username":username.value,
//             "password":password.value,"rememberMe":remember}
        axios.post("http://localhost:8080/Barbr/login?action=logIn",params).then(res => {
            console.log(res.data.state);
            /*if (res.data.state) {
                alert("jump");
                //location.href = "html/MembershipManagement.jsp";
            } else {
                alert("000");
                alert(res.data.msg)
            }*/
            location.href="http://localhost:8080/Barbr/html/MembershipManagement.jsp";
        })
    }
}